package biznussoft.metercor.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import biznussoft.metercor.R;
import biznussoft.metercor.entity.StockTransferLineModel;




public class StockTransferLineDetailsAdapter extends BaseAdapter {
	
	ArrayList<StockTransferLineModel> listdata;
	Context mContext;

	public StockTransferLineDetailsAdapter(Context context, ArrayList<StockTransferLineModel> list) {
		// TODO Auto-generated constructor stub
		this.listdata = list;
		this.mContext = context;
	}

	public int getCount() {     
		// TODO Auto-generated method stub
		try{
		return listdata.size();}
		catch(Exception ex){
			return 0;
		}
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public class ViewHolder{
		public TextView no;    
		public TextView serialId;
		public TextView itemId;
		public TextView qtyTransferred;
	}

	public View getView(int position, View v, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		ViewHolder holder;
		
		if(v == null){
			
			holder = new ViewHolder();
			LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = inflator.inflate(R.layout.display_fields, null);
			holder.no  = (TextView) v.findViewById(R.id.no);
			holder.serialId  = (TextView) v.findViewById(R.id.serialId);
			holder.itemId = (TextView) v.findViewById(R.id.itemId);
			holder.qtyTransferred = (TextView) v.findViewById(R.id.qtyTransferred);
			
			v.setTag(holder);
		}else{
			holder = (ViewHolder) v.getTag();
		}
		
		StockTransferLineModel bean = listdata.get(position);
		
			holder.no.setText(bean.getName());
			holder.itemId.setText(bean.getItem());
			holder.serialId.setText(bean.getSerialId());
			holder.qtyTransferred.setText(bean.getQtyTransferred());
		
		return v;
	}

}
